<%@page import="com.ksyzt.ksite2.server.common.PageNaviData"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.net.URL"%>
<%@page import="com.ksyzt.ksite2.shared.modle.NEWSObj"%>
<%@page import="com.ksyzt.ksite2.server.database.dao.INEWSDAO"%>
<%@page import="com.ksyzt.ksite2.server.database.dao.impl.NEWSDAOImpl"%>
<%@page import="com.ksyzt.ksite2.shared.modle.NEWSObjs"%>
<%@page
	import="com.ksyzt.ksite2.server.database.dao.impl.VW_NEWSDAOImpl"%>
<%@page import="com.ksyzt.ksite2.server.database.dao.IVW_NEWSDAO"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.ksyzt.ksite2.shared.modle.VW_NEWSObj"%>
<%@page import="com.ksyzt.ksite2.shared.modle.VW_NEWSObjs"%>
<%@page import="com.ksyzt.ksite2.client.column.ColumnType"%>
<%@page import="com.ksyzt.ksite2.shared.modle.COLUMNObjs"%>
<%@page import="com.ksyzt.ksite2.shared.modle.COLUMNObj"%>
<%@page import="com.ksyzt.ksite2.shared.PageData"%>
<%@page import="com.ksyzt.ksite2.server.common.Application"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	Application app=new Application(request,response);
	PageData pd=app.getApplicationPageData();
	
	int search_where=app.parameterAsInteger("type", 0);
	//1 标题 0 内容 
	String search_what=app.parameterCSharpAsString("w", "");
	search_what=URLDecoder.decode(search_what,"UTF-8");
	
	
	NEWSObjs ns=new NEWSObjs();
	int pagesize=app.parameterAsInteger("pagesize", 20);
	pagesize=Math.max(pagesize, 20);
	
	int currentpage=app.parameterAsInteger("page", 0);
	long count=0;
	long totalpage=0;
	INEWSDAO dao=new NEWSDAOImpl(Application.getConnection());
	if(search_what.length()==0)
	{
		count=dao.getCountByWhereTemplate("");
		ns=dao.getSpecificRecordByWhereTemplate("order by addtime desc", currentpage*pagesize, currentpage*pagesize+pagesize);
	}
	else
	{
		String search="%"+search_what+"%";
		if(search_where==1)
		{
	count=dao.getCountByWhereTemplate("where title like ?",search);
	ns=dao.getSpecificRecordByWhereTemplate("where title like ? order by addtime desc", currentpage*pagesize, currentpage*pagesize+pagesize,search);
		}
		else
		{
	count=dao.getCountByWhereTemplate("where content like ? ",search);
	ns=dao.getSpecificRecordByWhereTemplate("where content like ? order by addtime desc", currentpage*pagesize, currentpage*pagesize+pagesize,search);
		}
	}
	
	String url = "news/search.jsp?";
	url += "type=" + search_where;
	url += "&w=" + URLEncoder.encode(search_what);
	PageNaviData data=new PageNaviData(url,count,pagesize,currentpage);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=pd.getName()%>-搜索</title>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="<%=pd.getKeyWords()%>" />
<meta http-equiv="description" content="<%=pd.getSummary()%>" />
<link rel="stylesheet" type="text/css" href="css/comm.css" />
<style type="text/css">
.newslist {
	width: 950px;
	padding-top: 40px;
	padding-left: 5px;
}

.newslist-top {
	display: none;
	width: 100%;
	border: 1px solid #a8ccee;
	float: left;
	background: url(images/column_top.png) no-repeat;
	height: 34px;
	margin: 0px 0px 0px 0px;
}

.newslist-top-title {
	line-height: 34px;
	padding: 0px 0px 0px 18px;
	font-size: 14px;
	font-family: 宋体;
	font-weight: bold;
	color: #333;
}

.newslist-top-more {
	display: none;
	float: right;
	margin: 5px 6px 0px 0px;
	width: 41px;
	height: 17px;
}

.newslist-top-more-link {
	text-decoration: none;
	width: 41px;
	height: 17px;
	display: block;
	background: url(images/more1.gif) no-repeat;
}

.newslist-top-more-link:hover {
	width: 41px;
	height: 17px;
	display: block;
	background: url(images/more2.gif) no-repeat;
}

.newslist-top-tabs {
	border-top: solid 1px #9cd9f5;
	margin: 0px;
	padding: 0px;
	display: block;
}

.newslist-top-tabs ul {
	width: 100%;
	border-top: solid 1px #9cd9f5;
	margin: 0px;
}

.newslist-top-tabs .unselected {
	overflow: hidden;
	color: #505050;
	height: 26px;
	line-height: 26px;
	background: url(images/480_box_normal.gif) repeat-x;
	list-style: none;
	float: left;
	padding: 0px 2px 0px 2px;
	width: 115px;
	text-align: center;
	vertical-align: middle;
	cursor: pointer;
	border-bottom: solid 1px #a8ccee;
	border-left: solid 1px #a8ccee;
	border-collapse: separate;
	font-size: 12px;
	font-family: 宋体;
}

.newslist-top-tabs .selected {
	overflow: hidden;
	color: darkblue;
	font-weight: bold;
	text-decoration: none;
	height: 26px;
	line-height: 26px;
	background: url(images/480_box_select.gif) repeat-x;
	list-style: none;
	float: left;
	padding: 0px 2px 0px 2px;
	width: 115px;
	text-align: center;
	vertical-align: middle;
	cursor: pointer;
	border-bottom: solid 0px #9cd9f5;
	border-left: solid 1px #9cd9f5;
	font-size: 12px;
	font-family: 宋体;
}

.newslist-content {
	width: 100%;
}

.newslist-content-tab ul {
	margin: 5px 0px 0px 0px;
	padding: 0px;
}

.newslist-content-tab li {
	line-height: 200%;
	height: 30px;
	border-top: dashed 1px #505050;
	font-size: 12px;
	font-family: 宋体;
	list-style: none;
	padding: 0px 0px 0px 22px;
	background: url(images/item_indicator.png) 6px 9px no-repeat;
}

.newslist-content-tab a {
	width: 635px;
	text-decoration: none;
	color: #333;
	float: left;
	line-height: 30px;
	display: block;
	height: 26px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 12px;
	font-family: 宋体;
}

.newslist-content-tab a:hover {
	color: #014b90;
}

.newslist-content-tab span {
	font-size: 12px;
	float: left;
	width: 60px;
	display: block;
}

.newslist-content-tab li:FIRST-CHILD {
	border-top: solid 0px skyblue;
}

.pn {
	width: 970px;
}

.pn .navibar-middle {
	width: 950px;
}

.pagecontent {
	margin-left: 1px;
	padding: 5px;
}
</style>
<script src="js/swfobject_modified.js" type="text/javascript"></script>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.ksyzt.js"></script>
<script type="text/javascript">
	function load() {

		$(".stylish").makeStylish();

	}
	$(document).ready(load);
</script>
</head>

<body>
	<div class="wrap">
		<div class="wrap_center">
			<jsp:include page="../include/top.jsp" />

			<div class="w_970">
				<div class="pn">
					<div class='navibar-left'></div>
					<div class='navibar-middle'>
						<a href=''>首页</a>&nbsp;&gt;&nbsp;新闻搜索
						<form style="display: inline;" action="news/search.jsp"
							method="get" enctype="application/x-www-form-urlencoded">
							<table style="float:right;">
								<tr>
									<td><select name="type" class='search_select'>
											<%
												if (search_where == 0) {
											%>
											<option value="0" selected="selected">内容</option>
											<option value="1">标题</option>
											<%
												} else {
											%>
											<option value="0">内容</option>
											<option value="1" selected="selected">标题</option>

											<%
												}
											%>
									</select></td>
									<td><input name="w" type="text" value="<%=search_what%>" />
									</td>
									<td><input type="submit" value="搜索" />
									</td>
								</tr>
							</table>
						</form>

					</div>
					<div class='navibar-right'></div>
				</div>

				<div class='pagecontent'>

					<%
						if (count == 0) {
					%>
					<div class="message_box">对不起，没有找到您要查询的信息？</div>
					<%
						} else {
					%>
					<div class="stylish {css:'newslist'}">

						<div id="tabs">
							<div id="tab">
								<div id="title"></div>
								<ul>
									<%
										for (NEWSObj n : ns) {
												out.print("<li>");
												String link = n.getLINK();
												if (link != null && link.length() > 0) {

												} else {
													link = "news/article.jsp?id=" + n.getID();
												}

												out.print("<a href='" + link + "'>");
												out.print(n.getTITLE());
												out.print("</a>");
												out.print("<span>" + app.toDateString(n.getADDTIME())
														+ "</span>");
												out.print("</li>");
											}
									%>
								</ul>
							</div>
						</div>
					</div>
					<%
						}
					%>

					<!-- page navi -->
					<div class='news-navi'>

						<%
							out.print(app.toPagesNavigatorBar(data));
						%>
					</div>
				</div>

			</div>
		</div>
		<jsp:include page="../include/bottom.jsp" />
	</div>
</body>
</html>
